import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int [] a = {1,2,3,4,5,6};
        int i = 0;
        int j = a.length-1;
        while(i<j){
           while(i<j&&a[i]%2!=0){
                i++;
            }
            while(i<j&&a[i]%2==0){
                j--;
            }
           int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        System.out.println(Arrays.toString(a));
    }
}
